﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GameProtocols;

public class VisualAnimationComponent : VisualComponent
{
    VisualEntity mVEntity;
    Animator animator;

    public void DoFixedUpdate(float deltaTime)
    {
    }

    public void DoUpdate(float deltaTime)
    {
    }

    public void Init(VisualEntity vEntity)
    {
        mVEntity = vEntity;
        animator = vEntity.GetComponent<Animator>();

        mVEntity.RegistMsg((int)ProtoId.MSG_SETROTATION, onSetFaceDirection);
    }

    public void OnDestroy()
    {
        mVEntity.UnregistMsg((int)ProtoId.MSG_SETROTATION, onSetFaceDirection);
    }

    public void Start()
    {
    }

    void onSetFaceDirection(object[] content)
    {
        int faceRotation = (int)content[0];
        animator.SetBool("mirror", faceRotation == -1);
    }
}
